package com.xinghou.platform.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 语音文件处理
 * @author wzk
 *
 */
public class VoiceTools {
	/**
	 * 把字节数组保存为一个文件
	 * @param b
	 * @param outputFile
	 * @return
	 */
	public static boolean getFileFromBytes(byte[] b, File file) {
		BufferedOutputStream stream = null;
		try {
			FileOutputStream fstream = new FileOutputStream(file);
			stream = new BufferedOutputStream(fstream);
			stream.write(b);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			if (stream != null) {
				try {
					stream.close();
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
			}
		}
		return true;
	}
}
